﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Markup;
using System.Windows.Browser;
using Common;
using Common.Controls;
namespace SLAdmin
{
    public partial class Page : UserControl
    {
        StudyManager _studyManager = StudyManager.GetInstance();
        StudyDataClient _studyDataClient = new StudyDataClient();
        DialogHelper _dialogHelper = new DialogHelper();

        public Page()
        {
            InitializeComponent();            
        }
        public Grid MainGrid
        {
            get { return LayoutRoot; }
            set { LayoutRoot = value; }
        }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            _dialogHelper.LoginCompleted += new DialogHelper.LoginCompletedDelegate(_dialogHelper_LoginCompleted);
            _studyDataClient.LoadDataCompleted += new StudyDataClient.LoadDataCompletedDelegate(_studyDataClient_LoadDataCompleted);
            _dialogHelper.ForceLogin(this.MainGrid,App.Current,Guid.Empty);
        }

        void _studyDataClient_LoadDataCompleted()
        {
            SplitScreen l = new SplitScreen();
            l.SetValue(Grid.RowProperty, 0);
            LayoutRoot.Children.Add(l);
        }

        void _dialogHelper_LoginCompleted(bool LoginSuccess, int UserId)
        {
            if (LoginSuccess)
            {
                _studyDataClient.LoadData();
            }
            else
            {

            }
        }
                
    }
}
